package com.yf.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class BindService extends Service {
	class MyBinder extends Binder {
		public void showToast(String msg) {
			Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
		}
	}

	@Override
	public IBinder onBind(Intent intent) {
		Log.v("BindService", "onBind");
		// 只有当onBind返回值不为null时，才会调用ServiceConnection对象onServiceConnected方法
		return new MyBinder();
	}

	@Override
	public void onCreate() {
		Log.v("BindService", "onCreate");
		super.onCreate();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.v("BindService", "onStartCommand");
		return super.onStartCommand(intent, flags, startId);
	}

	@Override
	public void onDestroy() {
		Log.v("BindService", "onDestroy");
		super.onDestroy();
	}

}
